import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/home/index'
// import Category from '../views/category/index';
import Detail from "../views/detail/index";
import Blog from "../views/blog/index";
// import BlogAdd from "../views/blog/add";
// import BlogShow from "../views/blog/show";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home
    },
    {
        path: '/about',
        name: 'About',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
    },
    {
        path: '/category',
        name: 'Category',
        component: () => import('../views/category/index')
    },
    {
        path: '/detail/:id',
        name: 'DramaDetail',
        component: () => import('../views/detail/index')
    },
    {
        path: '/blog',
        component: () => import('@/views/blog/index'),
        children: [
            {
                path: '',
                component: () => import('../views/blog/show')
            },
            {
                path: 'add',
                component: () => import('../views/blog/add'),
                meta: {
                    role: 'user'
                }
            },
            {
                path: ':id',
                name: 'BlogDetail',
                component: () => import('../views/blog/detail')
            }
        ]
    },
    {
        path: '/pursuit',
        name: 'Pursuit',
        component: () => import('../views/pursuit/index'),
        meta: {
            role: 'user'
        }
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('../views/login/index')
    },
    {
        path: '/register',
        name: 'Register',
        component: () => import('../views/login/register')
    },
    {
        path: '/user/setting',
        name: 'Setting',
        component: () => import('../views/user/setting'),
        meta: {
            role: 'user'
        }
    },
    {
        path: '/userIndex',
        component: () => import('@/views/user/home'),
        children: [
            {
                path: 'blog',
                name: 'UserBlog',
                component: () => import('@/views/user/blog')
            }
        ]
    },
    {
        path: '/catelog',
        component: () => import('../views/catelog/index'),
        meta: {
            role: 'user'
        }
    },
    {
        path: '/catelog/:id',
        component: () => import('../views/catelog/detail')
    },
    {
        path: '/admin/login',
        name: 'adminLogin',
        component: () => import('../views/admin/Login')
    },
    {
        path: '/explore',
        component: () => import('../views/explore/index')
    },
    {
        path: '/search',
        component: () => import('@/views/search/index')
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
